import Konva from 'konva'
import { Vector2d } from 'konva/lib/types'
import EventBus from '../common/eventbus'
import { IndexGroup } from './index-group'

export type EventType = {
	tilesStatusChanged: State
	tilesRightClick: Menu
	tilesTileSelected: Konva.Group
}

export type Menu = {
	clientX: number, clientY: number
	items: Map<string, () => void>
}

export type State = {
	cursor: Vector2d
	scale: number
	select?: {
		selecting: boolean,
		start: Vector2d,
		end: Vector2d
	}
}

export type Context = State & {
	id: string
	gridsize: number
	eventbus: EventBus<EventType>,
	stage: Konva.Stage
	groups: {
		grid: Konva.Group
		tiles: IndexGroup
		ui: Konva.Group
	}
}